/*                This is Administrator filterscript
                 created by Emilijo (Correlli) Lovric
  ====================================================================
 *
 * Credits:
 *    SA-MP Team (for all functions)
 *    DracoBlue (dcmd, dudb, dini, dutils,
 *               SystemMessage, SystemMessageToAll,
 *               PlayerName, IsNumeric,
 *               DAntiCheat from which i made ServerLog)
 *    Sacky (fsearch)
 *    Y_Less (ReturnUser)
 *    kyeman (spectate commands which i turned to dcmd)
 *    Simon (IsInvalidSkin)
 *    Cam (SendMessageToAdmins from which i made a little
 *         different one for this script)
 *    And all others if i forgot someone
 *
 *
  ====================================================================

*/



#include "a_samp"
#include "dini"
#include "dutils"
#include "dudb"



#define COLOR_SYSTEM 0xF5FF9FAA
#define COLOR_ADMINISTRATOR 0xa0d3ffAA



#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1



#define KICKPORTAL "KickedNames.txt"



#define ADMIN_SPEC_TYPE_NONE 0
#define ADMIN_SPEC_TYPE_PLAYER 1
#define ADMIN_SPEC_TYPE_VEHICLE 2



forward Restart();



new IsPlayerMuted[MAX_PLAYERS];
new tmp[MAX_STRING];
new giveplayerid;
new bool:IsServerLocked;
new gSpectateID[MAX_PLAYERS];
new gSpectateType[MAX_PLAYERS];



dcmd_kick(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/kick [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been kicked by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
    format(string, sizeof(string), "Player %s has been kicked by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been kicked by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s kicked player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
	KickPlayer(giveplayerid, "");
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_ban(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/ban [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
	format(string, sizeof(string), "You have been banned by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
	SystemMessage(giveplayerid, string);
    if(dini_Exists(KICKPORTAL))
    {
    new File:fhandle;
    new temp[256];
    fhandle = fopen(KICKPORTAL, io_append);
    format(temp, sizeof(temp), "\n%s", PlayerName(giveplayerid));
    fwrite(fhandle, temp);
    fclose(fhandle);
    }
	format(string, sizeof(string), "Player %s has been banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s banned player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
	KickPlayer(giveplayerid, "");
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_say(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	new string[MAX_STRING];
    strmid(tmp, params, 4, strlen(params));
	if(!strlen(tmp))
	SendClientMessage(playerid, COLOR_SYSTEM, "Correct usage: '/say [text]'");
    else
	{
    format(string, sizeof(string), "%s: %s", PlayerName(playerid), tmp);
    printf(string);
    SendClientMessageToAll(COLOR_ADMINISTRATOR, string);
	}
    return 1;
}



dcmd_banip(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/banip [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
	giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
	format(string, sizeof(string), "You have been IP banned by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
	SendClientMessage(giveplayerid, COLOR_SYSTEM, string);
	format(string, sizeof(string), "Player %s has been IP banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	SendClientMessageToAll(COLOR_SYSTEM, string);
	format(string, sizeof(string), "%s has been IP banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string,sizeof(string),"Player %s IP banned player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
	BanPlayer(giveplayerid, "");
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SendClientMessage(playerid, COLOR_SYSTEM, string);
	}
    return 1;
}



dcmd_unbanip(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(params)) return SystemMessage(playerid, "Correct usage: '/unbanip [ip]'");
    new string[MAX_STRING];
	format(string, sizeof(string), "IP %s unbanned.", params);
    SystemMessage(playerid, string);
    format(string, sizeof(string), "unbanip %s", params);
	SendRconCommandEx(0, string);
	return 1;
}



dcmd_freeze(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/freeze [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been freezed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	FreezePlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been freezed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been freezed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s freezed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_unfreeze(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/unfreeze [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been unfreezed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	UnfreezePlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been unfreezed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been unfreezed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s unfreezed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_killplayer(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/killplayer [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been killed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	KillPlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been killed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been killed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s killed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_jail(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/jail [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been jailed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	JailPlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been jailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been jailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s jailed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_unjail(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/unjail [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been unjailed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	UnjailPlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been unjailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been unjailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s unjailed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_slap(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/slap [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been slapped by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	SlapPlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been slapped by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been slapped by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s slapped player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_mute(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/mute [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been muted by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	MutePlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been muted by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been muted by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s muted player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_unmute(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/unmute [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been unmuted by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	UnmutePlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been unmuted by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been unmuted by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s unmuted player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_explodeplayer(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/explodeplayer [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been exploded by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	ExplodePlayer(giveplayerid, "");
    format(string, sizeof(string), "Player %s has been exploded by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been exploded by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s exploded player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_resetweapons(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/resetweapons [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "Your all weapons have been reseted by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	ResetPlayerWeapons(giveplayerid);
    format(string, sizeof(string), "Administrator %s reseted all weapons on player %s. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), params);
    SystemMessageToAll(string);
	format(string, sizeof(string), "Administrator %s reseted all weapons on player %s. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s reseted all weapons to player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_restart(playerid, params[])
{
	#pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	SystemMessageToAll("Current gamemode will restart in 5 seconds.");
	SetTimer("Restart", 5000, 0);
    return 1;
}



dcmd_lockserver(playerid, params[])
{
	#pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	new string[MAX_STRING];
    IsServerLocked = true;
    format(string, sizeof(string), "Server has been locked by Administrator %s.", PlayerName(playerid));
   	SystemMessageToAll(string);
	print(string);
    return 1;
}



dcmd_unlockserver(playerid, params[])
{
	#pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	new string[MAX_STRING];
	IsServerLocked = false;
    format(string, sizeof(string), "Server has been unlocked by Administrator %s.", PlayerName(playerid));
   	SystemMessageToAll(string);
	print(string);
    return 1;
}



dcmd_specplayer(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/specplayer [playername]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
	giveplayerid = ReturnUser(tmp);
	if(IsPlayerConnected(giveplayerid))
	{
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectatePlayer(playerid, giveplayerid);
	SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
	gSpectateID[playerid] = giveplayerid;
	gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s started spectating player %s on %d/%d/%d at %d:%d:%d.", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second);
	ServerLog(string);
	printf(string);
	}
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
	return 1;
}



dcmd_specvehicle(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
    new specvehicleid;
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/specvehicle [vehicleid]'");
	return 1;
	}
	specvehicleid = strval(tmp);
	if(specvehicleid < MAX_VEHICLES)
	{
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectateVehicle(playerid, specvehicleid);
	gSpectateID[playerid] = specvehicleid;
	gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
	}
	else
	{
	SystemMessage(playerid, "Correct usage: '/specvehicle [vehicleid]'");
	}
	return 1;
}



dcmd_specoff(playerid, params[])
{
	#pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    TogglePlayerSpectating(playerid, 0);
    gSpectateID[playerid] = INVALID_PLAYER_ID;
    gSpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
	return 1;
}



dcmd_settime(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
    new time;
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	if(!strlen(tmp) || !IsNumeric(tmp))
	{
	SendClientMessage(playerid, COLOR_SYSTEM, "Correct usage: '/settime [hour]'");
	return 1;
	}
	time = strval(tmp);
	SetWorldTime(time);
	SystemMessage(playerid, "New time setted.");
	return 1;
}



dcmd_cs(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
    new skin;
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	if(!strlen(tmp) || !IsNumeric(tmp) || IsInvalidSkin(skin))
	{
	SystemMessage(playerid, "Correct usage: '/cs [skinid]'");
	return 1;
	}
	if(skin > 299 || skin < 0)
	{
	SystemMessage(playerid, "Pick a skin from 0-299.");
	return 1;
	}
	skin = strval(tmp);
	SetPlayerSkin(playerid, skin);
	SystemMessage(playerid, "Skin changed.");
	return 1;
}



dcmd_setweather(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(params)) return SystemMessage(playerid, "Correct usage: '/setweather [weatherid]'");
    new string[MAX_STRING];
    new index = 0;
    tmp = strtok(params, index);
    new toweatherid = strval(tmp);
    if(toweatherid < 41 && toweatherid > -1)
    {
	format(string, sizeof(string), "Setted new weather. (%d)", toweatherid);
    SystemMessage(playerid, string);
    format(string, sizeof(string), "weather %d", toweatherid);
	SendRconCommandEx(0, string);
	}
	else
	{
	SystemMessage(playerid, "Enter weather id from 0 to 40.");
	}
	return 1;
}



dcmd_setgravity(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(params)) return SystemMessage(playerid, "Correct usage: '/setgravity [gravity]'");
    new string[MAX_STRING];
    new index = 0;
    tmp = strtok(params, index);
    new Float:togravityid = floatstr(tmp);
    if(togravityid < 41 && togravityid > -1)
    {
	format(string, sizeof(string), "Setted new gravity. (%f)", togravityid);
    SystemMessage(playerid, string);
    format(string, sizeof(string), "gravity %f", togravityid);
	SendRconCommandEx(0, string);
	}
	else
	{
	SystemMessage(playerid, "Enter gravity id from 0 to 40.");
	}
	return 1;
}



dcmd_whois(playerid, params[])
{
    new index = 0;
	new playermoney;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/whois [playername]'");
	return 1;
	}
	new string[MAX_STRING];
	giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
	playermoney = GetPlayerMoney(giveplayerid);
	format(string, sizeof(string), "Whois (Name: %s, ID: %d, money: $%d)", PlayerName(giveplayerid), giveplayerid, playermoney);
	SystemMessage(playerid, string);
	}
	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
	return 1;
}



dcmd_skick(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/skick [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently kicked by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	format(string, sizeof(string), "%s has been silently kicked by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently kicked player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
	KickPlayer(giveplayerid, "");
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sban(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sban [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
	format(string, sizeof(string), "You have been silently banned by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
	SystemMessage(giveplayerid, string);
    if(dini_Exists(KICKPORTAL))
    {
    new File:fhandle;
    new temp[256];
    fhandle = fopen(KICKPORTAL, io_append);
    format(temp, sizeof(temp), "\n%s", PlayerName(giveplayerid));
    fwrite(fhandle, temp);
    fclose(fhandle);
    }
	format(string, sizeof(string), "%s has been silently banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently banned player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
	KickPlayer(giveplayerid, "");
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sbanip(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sbanip [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
	giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
	format(string, sizeof(string), "You have been silently IP banned by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
	SendClientMessage(giveplayerid, COLOR_SYSTEM, string);
	format(string, sizeof(string), "%s has been silently IP banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string,sizeof(string),"Player %s silently IP banned player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
	BanPlayer(giveplayerid, "");
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SendClientMessage(playerid, COLOR_SYSTEM, string);
	}
    return 1;
}



dcmd_sfreeze(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sfreeze [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently freezed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	FreezePlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently freezed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently freezed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sunfreeze(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sunfreeze [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently unfreezed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	UnfreezePlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently unfreezed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently unfreezed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_skillplayer(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/skillplayer [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently killed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	KillPlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently killed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently killed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sjail(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sjail [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently jailed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	JailPlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently jailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently jailed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sunjail(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sunjail [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently unjailed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	UnjailPlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently unjailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently unjailed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sslap(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sslap [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently slapped by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	SlapPlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently slapped by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently slapped player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_smute(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/smute [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently muted by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	MutePlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently muted by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently muted player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sunmute(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sunmute [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently unmuted by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	UnmutePlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently unmuted by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently unmuted player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sexplodeplayer(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sexplodeplayer [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "You have been silently exploded by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	ExplodePlayer(giveplayerid, "");
	format(string, sizeof(string), "%s has been silently exploded by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently exploded player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_sresetweapons(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/sresetweapons [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "Your all weapons have been silently reseted by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
    SystemMessage(giveplayerid, string);
	ResetPlayerWeapons(giveplayerid);
	format(string, sizeof(string), "Administrator %s silently reseted all weapons on player %s. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s silently reseted all weapons to player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_createmoney(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
    new createmoney;
    new string[MAX_STRING];
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	if(!strlen(params))
	{
	SystemMessage(playerid, "Correct usage: '/createmoney [amount]'");
	return 1;
	}
	if (createmoney < 0)
	{
    SystemMessage(playerid, "Correct usage: '/createmoney [amount]'");
    return 1;
	}
	createmoney = strval(tmp);
    format(string, sizeof(string), "You created $%d.", createmoney);
    SystemMessage(playerid, string);
    GivePlayerMoney(playerid, createmoney);
    return 1;
}



dcmd_deletemoney(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
    new deletemoney;
    new string[MAX_STRING];
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	if(!strlen(params))
	{
	SystemMessage(playerid, "Correct usage: '/deletemoney [amount]'");
	return 1;
	}
	if (deletemoney < 0)
	{
    SystemMessage(playerid, "Correct usage: '/deletemoney [amount]'");
    return 1;
	}
	if (deletemoney > GetPlayerMoney(playerid))
	{
    SystemMessage(playerid, "You don't have that much money to delete.");
	return 1;
	}
	deletemoney = strval(tmp);
    format(string, sizeof(string), "You deleted $%d.", deletemoney);
    SystemMessage(playerid, string);
    GivePlayerMoney(playerid, -deletemoney);
    return 1;
}



dcmd_srestart(playerid, params[])
{
	#pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	SystemMessage(playerid, "Current server gamemode will now silently restart in 5 seconds.");
	SetTimer("Restart", 5000, 0);
    return 1;
}



dcmd_slockserver(playerid, params[])
{
	#pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    IsServerLocked = true;
	SystemMessage(playerid, "You have silently locked server.");
    return 1;
}



dcmd_sunlockserver(playerid, params[])
{
	#pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	IsServerLocked = false;
    SystemMessage(playerid, "You have silently unlocked server.");
    return 1;
}



dcmd_report(playerid, params[])
{
	new index = 0;
    tmp = strtok(params, index);
    if(!strlen(tmp))
	{
	SystemMessage(playerid, "Correct usage: '/report [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp);
	if (IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "Report was sent to currently administrators/moderators online.");
    SystemMessage(giveplayerid, string);
	format(string, sizeof(string), "Report: %s has reported %s. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), params);
    SendMessageToAdministrators(string);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s reported player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
    }
   	else
    {
	format(string, sizeof(string), "That player is not active.");
	SystemMessage(playerid, string);
	}
    return 1;
}



dcmd_changemode(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	if(!strlen(params)) return SystemMessage(playerid, "Correct usage: '/changemode [gamemodename]'");
    new string[MAX_STRING];
    format(string, sizeof(string), "Changing gamemode to %s.amx", params);
    SystemMessage(playerid, string);
    format(string, sizeof(string), "changemode %s", params);
	SendRconCommandEx(2000, string);
	return 1;
}



dcmd_reloadbans(playerid, params[])
{
    #pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    new string[MAX_STRING];
    format(string, sizeof(string), "samp.ban log reseted.");
    SystemMessage(playerid, string);
    format(string, sizeof(string), "reloadbans");
	SendRconCommandEx(0, string);
	return 1;
}



dcmd_reloadlog(playerid, params[])
{
    #pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    new string[MAX_STRING];
    format(string, sizeof(string), "server_log.txt log reseted.");
    SystemMessage(playerid, string);
    format(string, sizeof(string), "reloadlog");
	SendRconCommandEx(0, string);
	return 1;
}



dcmd_players(playerid, params[])
{
    #pragma unused params
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    new string[MAX_STRING];
	SendRconCommand("players");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if(IsPlayerConnected(i))
    {
	SystemMessageEx(playerid, 0, "     ID     Name   Ping   IP");
	format(string, sizeof(string), "     %d     %s     %d     %s", i, PlayerName(i), PlayerPing(i), PlayerIp(i));
	SystemMessageEx(playerid, 2000, string);
	}
	}
	return 1;
}



dcmd_loadfs(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(params)) return SystemMessage(playerid, "Correct usage: '/loadfs [filterscriptname]'");
    new string[MAX_STRING];
	format(string, sizeof(string), "Filterscript %s.amx loaded.", params);
    SystemMessage(playerid, string);
    format(string, sizeof(string), "loadfs %s", params);
	SendRconCommandEx(0, string);
	return 1;
}



dcmd_unloadfs(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
	if(!strlen(params)) return SystemMessage(playerid, "Correct usage: '/unloadfs [filterscriptname]'");
    new string[MAX_STRING];
    format(string, sizeof(string), "Filterscript %s.amx unloaded.", params);
    SystemMessage(playerid, string);
    format(string, sizeof(string), "unloadfs %s", params);
	SendRconCommandEx(0, string);
	return 1;
}



dcmd_reloadfs(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
    if(!strlen(params)) return SystemMessage(playerid, "Correct usage: '/reloadfs [filterscriptname]'");
    new string[MAX_STRING];
    format(string, sizeof(string), "Filterscript %s.amx reloaded.", params);
    SystemMessage(playerid, string);
    format(string, sizeof(string), "reloadfs %s", params);
	SendRconCommandEx(0, string);
	return 1;
}



public Restart()
{
    GameModeExit();
}



stock SystemMessage(playerid, message[])
{
    if ((IsPlayerConnected(playerid)) && (strlen(message) > 0))
	{
    SendClientMessage(playerid, COLOR_SYSTEM, message);
    }
    return 1;
}



stock SystemMessageEx(playerid, time, message[])
{
    if ((IsPlayerConnected(playerid)) && (strlen(message) > 0))
	{
	Wait(time);
    SystemMessage(playerid, message);
    }
    return 1;
}



stock SystemMessageToAll(message[])
{
    for(new i=0; i<MAX_PLAYERS; i++)
	{
    if ((IsPlayerConnected(i)) && (strlen(message) > 0))
	{
    SendClientMessage(i, COLOR_SYSTEM, message);
    }
    }
    return 1;
}



stock SendMessageToAdministrators(string[])
{
   	for (new i = 0; i < MAX_PLAYERS; i++)
	{
	if (IsPlayerConnected(i))
	{
    if (IsPlayerAdmin(i))
	{
	SystemMessage(i, string);
	}
	}
	}
	return 1;
}



stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}



stock PlayerIp(playerid)
{
   	new ip[16];
	GetPlayerIp(playerid, ip, sizeof(ip));
	return ip;
}



stock PlayerPing(playerid)
{
    if (!IsPlayerConnected(playerid)) return 0;
	new ping = GetPlayerPing(playerid);
	return ping;
}



stock ServerLog(message[])
{
    new File:fhnd;
    if (fexist("ServerLog.log.txt"))
	fhnd = fopen("ServerLog.log.txt", io_append);
	else
    fhnd = fopen("ServerLog.log.txt", io_write);
    fwrite(fhnd, message);
    fputchar(fhnd, 13);
    fputchar(fhnd, 10);
    fclose(fhnd);
}



stock KickPlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
    SystemMessage(playerid, reason);
    TogglePlayerControllable(playerid, 0);
    Kick(playerid);
    }
	return 1;
}



stock BanPlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
    SystemMessage(playerid, reason);
    TogglePlayerControllable(playerid, 0);
    Ban(playerid);
    }
	return 1;
}



stock FreezePlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
    SystemMessage(playerid, reason);
    TogglePlayerControllable(playerid, 0);
    }
	return 1;
}



stock UnfreezePlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
    SystemMessage(playerid, reason);
    TogglePlayerControllable(playerid, 1);
    }
	return 1;
}



stock KillPlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
    SystemMessage(playerid, reason);
    SetPlayerHealth(playerid, 0.0);
    }
	return 1;
}



stock JailPlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
	SystemMessage(playerid, reason);
	SetPlayerFacingAngle(playerid, 177.0350);
	SetCameraBehindPlayer(playerid);
	SetPlayerInterior(playerid, 3);
	SetPlayerPos(playerid, 197.7029,174.8801,1003.0234);
    }
	return 1;
}



stock UnjailPlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
	SystemMessage(playerid, reason);
	SpawnPlayer(playerid);
    }
	return 1;
}



stock SlapPlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
	SystemMessage(playerid, reason);
	new Float:phealth;
	GetPlayerHealth(playerid, phealth);
	SetPlayerHealth(playerid, phealth-20);
    }
	return 1;
}



stock MutePlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
	SystemMessage(playerid, reason);
	IsPlayerMuted[playerid] = true;
    }
	return 1;
}



stock UnmutePlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
	SystemMessage(playerid, reason);
	IsPlayerMuted[playerid] = false;
    }
	return 1;
}



stock ExplodePlayer(playerid, reason[])
{
    if (IsPlayerConnected(playerid))
	{
	SystemMessage(playerid, reason);
	new Float:XPOS;
	new Float:YPOS;
	new Float:ZPOS;
	GetPlayerPos(playerid, XPOS, YPOS, ZPOS);
	CreateExplosion(XPOS, YPOS, ZPOS, 3, 5);
    }
	return 1;
}



stock fsearch(filename[], search[], bool:caps = false)
{
    new File:fhandle = fopen(filename, io_read);
	new temp[255];
	while(fread(fhandle, temp))
	{
	StripNewLine(temp);
	if(equal(temp, search, caps)) return true;
	}
	return false;
}



stock IsNumeric(const string[])
{
	for (new i = 0, j = strlen(string); i < j; i++)
	if (string[i] > '9' || string[i] < '0')
    return 0;
	return 1;
}



ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
	new pos = 0;
	while (text[pos] < 0x21)
	{
	if (text[pos] == 0) return INVALID_PLAYER_ID;
	pos++;
	}
	new userid = INVALID_PLAYER_ID;
	if (IsNumeric(text[pos]))
	{
	userid = strval(text[pos]);
	if (userid >=0 && userid < MAX_PLAYERS)
	{
	if(!IsPlayerConnected(userid))
	{
	userid = INVALID_PLAYER_ID;
	}
	else
	{
	return userid;
	}
	}
	}
	new len = strlen(text[pos]);
	new count = 0;
	new name[MAX_PLAYER_NAME];
	for (new i = 0; i < MAX_PLAYERS; i++)
	{
	if (IsPlayerConnected(i))
	{
	GetPlayerName(i, name, sizeof (name));
	if (strcmp(name, text[pos], true, len) == 0)
	{
	if (len == strlen(name))
	{
	return i;
	}
	else
	{
	count++;
	userid = i;
	}
	}
	}
	}
	if (count != 1)
	{
	if (playerid != INVALID_PLAYER_ID)
	{
	if (count)
	{
	SendClientMessage(playerid, COLOR_SYSTEM, "There are multiple users, enter full playername.");
	}
	else
	{
	SendClientMessage(playerid, COLOR_SYSTEM, "Playername not found.");
	}
	}
	userid = INVALID_PLAYER_ID;
	}
	return userid;
}



stock IsInvalidSkin(skinid)
{
	#define	MAX_BAD_SKINS   22
	new badSkins[MAX_BAD_SKINS] =
	{
	3, 4, 5, 6, 8, 42, 65, 74, 86,
	119, 149, 208, 265, 266, 267,
	268, 269, 270, 271, 272, 273, 289
	};
	for (new i = 0; i < MAX_BAD_SKINS; i++)
	{
    if (skinid == badSkins[i]) return true;
	}
	return false;
}



stock Wait(time)
{
    new stamp = tickcount();
    while (tickcount() - stamp < time){}
    return 1;
}



stock SendRconCommandEx(time, command[])
{
	Wait(time);
    SendRconCommand(command);
	return 1;
}



public OnFilterScriptInit()
{
	printf("    <>  Administrator filterscript loaded  <>    ");
	printf("    <>     by Emilijo (Correlli) Lovric    <>    ");
	return 1;
}



public OnFilterScriptExit()
{
	printf("    <>  Administrator filterscript unloaded  <>    ");
	printf("    <>      by Emilijo (Correlli) Lovric     <>    ");
	return 1;
}



public OnPlayerConnect(playerid)
{
    new string[MAX_STRING];
    new second, minute, hour, day, month, year;
    IsPlayerMuted[playerid] = 0;

   	if(fsearch("KickedNames.txt", PlayerName(playerid), true))
    {
    SystemMessage(playerid, "Your name has been banned on this server.");
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s tried to join server with banned name on %d/%d/%d at %d:%d:%d.", PlayerName(playerid), month, day, year, hour, minute, second);
    KickPlayer(playerid, "");
	}

	else if(IsServerLocked == true)
    {
    SystemMessage(playerid, "    Server is currently locked down by Administrator.");
    SystemMessage(playerid, "    Please try connecting later.");
    KickPlayer(playerid, "");
    }
	return 1;
}



public OnPlayerDisconnect(playerid, reason)
{
	IsPlayerMuted[playerid] = 0;
	return 1;
}



public OnPlayerText(playerid, text[])
{
	if (IsPlayerMuted[playerid] == 1)
	{
	SystemMessage(playerid, "You can't speak while you are muted!");
	return 0;
	}
	return 1;
}



public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(kick, 4, cmdtext);
    dcmd(ban, 3, cmdtext);
    dcmd(say, 3, cmdtext);
    dcmd(banip, 5, cmdtext);
    dcmd(unbanip, 7, cmdtext);
    dcmd(freeze, 6, cmdtext);
    dcmd(unfreeze, 8, cmdtext);
    dcmd(killplayer, 10, cmdtext);
    dcmd(jail, 4, cmdtext);
    dcmd(unjail, 6, cmdtext);
    dcmd(slap, 4, cmdtext);
    dcmd(mute, 4, cmdtext);
    dcmd(unmute, 6, cmdtext);
    dcmd(explodeplayer, 13, cmdtext);
    dcmd(resetweapons, 12, cmdtext);
    dcmd(restart, 7, cmdtext);
    dcmd(lockserver, 10, cmdtext);
    dcmd(unlockserver, 12, cmdtext);
    dcmd(specplayer, 10, cmdtext);
    dcmd(specvehicle, 11, cmdtext);
    dcmd(specoff, 7, cmdtext);
    dcmd(settime, 7, cmdtext);
    dcmd(cs, 2, cmdtext);
    dcmd(setweather, 10, cmdtext);
    dcmd(setgravity, 10, cmdtext);
    dcmd(whois, 5, cmdtext);
    dcmd(skick, 5, cmdtext);
    dcmd(sban, 4, cmdtext);
    dcmd(sbanip, 6, cmdtext);
    dcmd(sfreeze, 7, cmdtext);
    dcmd(sunfreeze, 9, cmdtext);
    dcmd(skillplayer, 11, cmdtext);
    dcmd(sjail, 5, cmdtext);
    dcmd(sunjail, 7, cmdtext);
    dcmd(sslap, 5, cmdtext);
    dcmd(smute, 5, cmdtext);
    dcmd(sunmute, 7, cmdtext);
    dcmd(sexplodeplayer, 14, cmdtext);
    dcmd(sresetweapons, 13, cmdtext);
    dcmd(createmoney, 11, cmdtext);
    dcmd(deletemoney, 11, cmdtext);
    dcmd(srestart, 8, cmdtext);
    dcmd(slockserver, 11, cmdtext);
    dcmd(sunlockserver, 13, cmdtext);
    dcmd(report, 6, cmdtext);
    dcmd(changemode, 10, cmdtext);
    dcmd(reloadbans, 10, cmdtext);
    dcmd(reloadlog, 9, cmdtext);
    dcmd(players, 7, cmdtext);
    dcmd(loadfs, 6, cmdtext);
    dcmd(unloadfs, 8, cmdtext);
    dcmd(reloadfs, 8, cmdtext);
	return 0;
}
